<%--
  Created by IntelliJ IDEA.
  User: 钱多多的钱罐罐
  Date: 2022/3/17
  Time: 14:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    //post乱码：转化成utf-8
    request.setCharacterEncoding("utf-8");
    //获取用户名、密码、爱好
    String username=request.getParameter("username");
    String password=request.getParameter("password");
    if (username.equals("海燕")&&password.equals("123")) {
        Cookie user=new Cookie("user",username);
        Cookie pwd=new Cookie("pwd",password);
        response.addCookie(user);
        response.addCookie(pwd);
        session.setAttribute("user",username);
        //给session设置时长，以秒为单位
        session.setMaxInactiveInterval(15);
        //转发
        //request.getRequestDispatcher("success2.jsp").forward(request,response);
        //重定向
        response.sendRedirect("success2.jsp");
    }else {

        //转发
       // request.getRequestDispatcher("login.jsp").forward(request,response);
        response.sendRedirect("login.jsp");
    }
%>
</body>
</html>
